<?php
class DB{
    static $obj=null;
    private function __construct()
    {
        echo "mysql connting....";
    }
    static function getobj(){
        if(is_null(self::$obj))
        {
            self::$obj=new DB();

        }
        return self::$obj;
//        else{
//            echo self::$obj;
//        }

    }
    public function select(){
        echo "select";
    }
}
var_dump(DB::getobj());
DB::getobj();
echo "<br/>";

class Printer{
    static $val=null;
    private function __construct()
    {
        echo "printing...";
    }
    static function getInstance()
    {
        if(is_null(self::$val)){
            self::$val=new self();
        }
        return self::$val;
    }
    public function printt($a)
    {
        echo $a;
    }
}
var_dump(Printer::getInstance());
var_dump(Printer::getInstance());